<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="应聘者">
              <select-hr-apply-bill-input
                    v-model="queryParam.applyId"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="应聘岗位">
              <j-search-select
                v-model="queryParam.positionId"
                dict="sys_position,name,id,del_flag = 0 and audit_status=2"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="入职部门">
              <j-select-depart  v-model="queryParam.departmentId" treeOpera/>
            </a-form-item>
          </a-col>
          <a-col  :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="所属团队" >
              <select-team-input
                        placeholder="请选择所属团队"
                        v-model="queryParam.teamId"
                        :teamType="0"
                        :tdlx="3" />
            </a-form-model-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="到岗时间">
              <a-range-picker v-model="createTimeRange"
                              format="YYYY-MM-DD"
                              :placeholder="['开始时间', '结束时间']"
                              @change="onCreateTimeChange" />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="createTimeRange=[],searchReset()" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('入职申请清单')" :disabled="isDisabledAuth('erpHrInductionBill:export')">导出</a-button>
      <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpHrInductionBill:import')">导入</a-button>
      </a-upload> -->
      <!-- 高级查询区域 -->
      <!--<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item,index) in defColumns">
                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                  <a-col :span="12"><a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox></a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right;"><a-icon type="setting" :style='iconStyle'/></a>
      </a-popover>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:'100%'}"
        :components="draggableComponent"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <a slot="name" slot-scope="text, record" @click="getDetail(record.id)">{{ text }}</a>
        
        <template slot="status" slot-scope="status">
           <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
      </a-table>
    </div>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import { getAction,postAction } from '@/api/manage'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'
  import SelectHrApplyBillInput from '@/views/scy/components/SelectHrApplyBillInput'
  import JSearchSelect from '@views/erp/hr/apply/modules/JSearchSelect.vue'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput';
  import moment from 'moment'

  export default {
    name: 'ErpHrInductionBillList',
    mixins:[JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
    components: {
      SelectHrApplyBillInput,
      JSearchSelect,
      SelectTeamInput
    },
    data () {
      return {
        description: '入职申请单管理页面',
        //表头
        columns:[],
        //列设置
        settingColumns:[],
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'入职人员',
            align:"center",
            width:100,
            dataIndex: 'applyId_dictText',
            scopedSlots: { customRender: 'name' },
            ellipsis: true,
          },
          {
            title:'入职岗位',
            align:"center",
            width:200,
            dataIndex: 'positionId_dictText',
            ellipsis: true,
          },
          {
            title:'入职部门',
            align:"center",
            width:300,
            dataIndex: 'departmentId_dictText',
            ellipsis: true,
          },
          {
            title:'所属团队',
            align:"center",
            width:300,
            dataIndex: 'teamId_dictText',
            ellipsis: true,
          },
         {
            title:'到岗时间',
            align:"center",
            width:200,
            dataIndex: 'arrivalTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            },
            ellipsis: true,
          },
          {
            title:'试用期',
            align:"center",
            width:200,
            dataIndex: 'probationership_dictText',
            ellipsis: true,
          },
          {
            title:'转正后薪资（元）',
            align:"center",
            width:200,
            dataIndex: 'conversionSalary',
            ellipsis: true,
          },
        ],
        url: {
          list: "/api/erp/hr/induction/erpHrInductionBill/allList",
          exportXlsUrl: "/api/erp/hr/induction/erpHrInductionBill/exportXls",
          importExcelUrl: "api/erp/hr/induction/erpHrInductionBill/importExcel",
        },
        dictOptions:{},
        superFieldList:[],
        createTimeRange:[]
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      searchReset(){
        this.queryParam = {}
        this.loadData(1)
      },
      onCreateTimeChange(dateString) {
        this.queryParam.arrivalTime_begin=moment(dateString[0]).format('YYYY-MM-DD');
        this.queryParam.arrivalTime_end=moment(dateString[1]).format('YYYY-MM-DD');
      },
      //查看详情
      getDetail(id) {
        this.$router.push({
          path: `/erp/hr/induction/ErpHrInductionBillListDetail/${id}`,
        })
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'applyId',text:'应聘申请单',dictCode:''})
        fieldList.push({type:'string',value:'applyUnit',text:'入职单位',dictCode:''})
        fieldList.push({type:'sel_depart',value:'departmentId',text:'入职部门'})
        fieldList.push({type:'string',value:'positionId',text:'入职岗位',dictCode:''})
        fieldList.push({type:'string',value:'inductionType',text:'入职类型',dictCode:''})
        fieldList.push({type:'string',value:'teamId',text:'所属团队',dictCode:''})
        fieldList.push({type:'string',value:'probationership',text:'试用期',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'conversionSalary',text:'转正薪资',dictCode:''})
        fieldList.push({type:'string',value:'trialSalary',text:'试用薪资',dictCode:''})
        fieldList.push({type:'string',value:'feeTeamId',text:'费用所属团队',dictCode:''})
        fieldList.push({type:'string',value:'insuredUnit',text:'参保单位',dictCode:''})
        fieldList.push({type:'string',value:'insuredBase',text:'参保基数（元）',dictCode:''})
        fieldList.push({type:'string',value:'workType',text:'工作类型',dictCode:''})
        fieldList.push({type:'date',value:'arrivalTime',text:'到岗时间'})
        fieldList.push({type:'BigDecimal',value:'practicingGold',text:'执业金（元）',dictCode:''})
        fieldList.push({type:'string',value:'remark',text:'备注',dictCode:''})
        fieldList.push({type:'Text',value:'attachments',text:'附件',dictCode:''})
        fieldList.push({type:'string',value:'bpmStatus',text:'流程状态',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
